using System.Text;

namespace 进程通讯.服务端
{
    public partial class Form1 : Form
    {
        SocketServer SocketServer=new SocketServer();
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SocketServer.Close();
            button1.Enabled = true;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (SocketServer.Listen("127.0.0.1", 8001))
            {
                SocketServer.Receive += SocketServer_Receive;
                button1.Enabled= false;
            }
        }

        private void SocketServer_Receive(System.Net.EndPoint arg1, byte[] arg2)
        {
            string msg = Encoding.UTF8.GetString(arg2);
            MessageBox.Show("接收到的" + arg1.ToString + "的数据:"+msg);
        }
    }
}